<?php

use think\migration\Migrator;
use think\migration\db\Column;

class SystemUser extends Migrator
{
    /**
     * Change Method.
     *
     * Write your reversible migrations using this method.
     *
     * More information on writing migrations is available here:
     * http://docs.phinx.org/en/latest/migrations.html#the-abstractmigration-class
     *
     * The following commands can be used in this method and Phinx will
     * automatically reverse them when rolling back:
     *
     *    createTable
     *    renameTable
     *    addColumn
     *    renameColumn
     *    addIndex
     *    addForeignKey
     *
     * Remember to call "create()" or "update()" and NOT "save()" when working
     * with the Table class.
     */
    public function change()
    {
	    $table = $this->table('system_user',['engine'=>'InnoDb']);
	    $table->addColumn(Column::string('account')->setDefault('')->setComment('账号')->setLimit(25))
		    ->addColumn(Column::string('passwd')->setDefault('')->setComment('密码')->setLimit(64))
		    ->addColumn(Column::string('avatar')->setDefault('')->setComment('头像')->setLimit(150))
		    ->addColumn(Column::char('mobile')->setDefault('')->setComment('手机号码')->setLimit(11))
		    ->addColumn(Column::string('email')->setDefault('')->setComment('邮箱')->setLimit(50))
		    ->addColumn(Column::string('last_login_ip')->setDefault('')->setComment('最后登录ip')->setLimit(15))
		    ->addColumn(Column::integer('login_cnt')->setDefault(0)->setComment('登录次数')->setLimit(11))
		    ->addColumn(Column::integer('last_login_time')->setDefault(0)->setComment('添加时间')->setLimit(10))
		    ->addColumn(Column::tinyInteger('status')->setDefault(1)->setComment('状态 0禁用')->setLimit(1))
		    ->addColumn(Column::integer('role_id')->setDefault(0)->setComment('角色id')->setLimit(11))
		    ->addColumn(Column::string('mark_lang')->setDefault('')->setComment('语言标识')->setLimit(5))
		    ->addColumn(Column::integer('deletetime')->setDefault(null)->setNull(true)->setComment('删除时间')->setLimit(10))
		    ->addColumn(Column::integer('createtime')->setDefault(0)->setComment('添加时间')->setLimit(10))
		    ->addColumn(Column::integer('updatetime')->setDefault(0)->setComment('添加时间')->setLimit(10))
		    ->create();
    }
}
